<style>
.flow-files{width: 100%; height: auto;}
.flow-files li{display: inline-block; width: 160px; height: 130px; padding:10px; margin-bottom: 15px; text-align: center; background-color:#f5f5f5}
.flow-files img{max-width:160px; height:90px;}
.flow-files li p{margin-bottom: 5px;}
.flow-files .selected{background-color:#DDDDFF; border-radius: 5px 25px}
.nav {width: 100%; height: 90px; box-shadow: 0 1px 1px 0 #CCC; background: #FFF; position: fixed; left: 0; top: 0; z-index: 999; overflow: hidden; transition: 0.3s}
.nav .layui-act-area{position: relative; transition: all 400ms ease-out; margin-top: 10px; margin-left: 15px}
.layui-form{margin-top: 90px}
</style>
<div class="layui-row nav">
	<div class="layui-act-area">
		<div class="layui-row">
			<div class="layui-btn-group">
				<button class="layui-btn layui-btn-sm #if(!folder) layui-btn-disabled #end" onclick="back();"><i class="layui-icon layui-icon-return"></i> 上一级</button>
				<button class="layui-btn layui-btn-sm" onclick="reload();"><i class="layui-icon layui-icon-refresh"></i> 刷新</button>
			</div>
			<div class="layui-btn-group">
				<button class="layui-btn layui-btn-sm layui-btn-warm" id="ID_btn_upload"><i class="layui-icon layui-icon-upload"></i> 上传</button>
				<button class="layui-btn layui-btn-sm layui-btn-normal" onclick="newFolder();"><i class="layui-icon layui-icon-add-1"></i> 新文件夹</button>
				<button class="layui-btn layui-btn-sm layui-btn-danger" onclick="delFiles();"><i class="layui-icon layui-icon-delete"></i> 删除勾选项</button>
			</div>
			<div class="layui-btn-group" style="float: right; margin-right: 20px">
				<button class="layui-btn layui-btn-sm layui-btn-normal ck-select-btn" onclick="ckSelectFiles();" style="display: none;"><i class="layui-icon layui-icon-ok"></i> 选择变色项</button>
			</div>
		</div>

		<div class="layui-row">
			<hr class="layui-bg-gray">
			<p class="layui-breadcrumb">
				<a href="javascript:getList('go');">根</a>
			#set(folerPath = "")
			#for(folder : folders)
				#set(folerPath = folderPath + "/" + folder)
				#if(for.last)
				<a><cite>#(folder)</cite></a>
				#else
				<a href="javascript:getList('go', '#(folderPath)');">#(folder)</a>
				#end
			#end
			</p>
		</div>
	</div>
</div>
<div class="layui-row layui-form layui-anim layui-anim-scale">
	<ul class="flow-files" id="ID_files">
	#if(folder)
		<li>
			<a #if(folder)href="javascript:getList('back', '#(folder)');"#else href="#" #end>
				<p style="height: 90px"><i class="layui-icon layui-icon-return" style="font-size: 80px"></i></p>
			</a>
			<p><input type="checkbox" lay-skin="primary" title="上一级"></p>
			<p class="layui-elip">[..]<p>
		</li>
	#end
	#for(file : files)
		#if(file.type == "folder")
		<li>
			<a href="javascript:getList('go', '#(folder)/#(file.name)');">
				<p><img lay-src="#(ctx)/manage/_assets/images/icon/folder_96.png"></p>
			</a>
			<p><input type="checkbox" lay-skin="primary" title="文件夹（#(file.size) 项）" file="#(file.name)"></p>
			<p class="layui-elip" title="#(file.name)">#(file.name)</p>
		</li>
		#else if(accept == "" || (accept != "" && file.type == accept))
		<li>
			<a class="jfsa-file">
				<p title="#(file.name)"><img lay-src='#if(file.type == "image") #(ctx)/upload/#(folder)/#(file.name) #else #(ctx)/manage/_assets/images/icon/#(file.type)_96.png #end'></p>
			</a>
			<p><input type="checkbox" lay-skin="primary" title="#(file.size)" file="#(file.name)"></p>
			<p class="layui-elip" title="#(file.name)">#(file.name)</p>
		</li>
		#else
		#end
	#end
	</ul>
</div>

<script>
$("#ID_folder").val("#(folder)");
upload.render({
	elem : '#ID_btn_upload',
	url : '#(ctx)/manage/files/ajaxUpload?folder=' + $("#ID_folder").val(),
	size : 2048,
	multiple : true,
	accept : "file",
	before : function(obj) {
		layer.load(1);
	},
	done : function(res) {
		if (res.code == 0) {
			layer.msg("操作成功");
			reload();
		} else {
			layer.alert("操作失败：" + res.msg);
		}
		layer.closeAll('loading');
	},
	error : function(res) {
		layer.alert("操作失败！");
		layer.closeAll('loading');
	}
});

$(".jfsa-file").click(function(){
	selectedItem($(this).parent());
});

if($("#ID_CKEditor").val() != ""){
	$(".ck-select-btn").show();
}
</script>
